package com.fyzk.bean;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class TimeZhuanHuan {
	
//	private static Handler netTimeHandler = new Handler();
	
	private static Runnable netTimeRunnable;
//	public static long netTime = 0;

	/**
	 * 时间转换
	 * @param string 格式为2011-06-28T19:30:00.000+0800
	 * @return
	 */
	public static long getTime(String string){
		String str = "";
		long times = 0;
		int y = 0;
		int m = 0;
		int d = 0;
		int h = 0;
		int min = 0;
		int s = 0;
		int sss = 0;
		
		String date = "";
		String time = "";
		String year = "";
		String month = "";
		String day = "";
		String hour ="";
		String minute = "";
		String second = "";
		String ms = "";
		try {
		str = string.split("\\+")[0];
		date = str.split("T")[0];
		time = str.split("T")[1];
		
		year = date.split("-")[0];
		month = date.split("-")[1];
		day = date.split("-")[2];
		
		hour = time.split(":")[0];
		minute = time.split(":")[1];
		second = time.split(":")[2].split("\\.")[0];
		ms = time.split(":")[2].split("\\.")[1];
		
			y = Integer.parseInt(year);
			m = Integer.parseInt(month);
			d = Integer.parseInt(day);
			h = Integer.parseInt(hour);
			min = Integer.parseInt(minute);
			s = Integer.parseInt(second);
			sss = Integer.parseInt(ms);
			
			Calendar calendar = new SimpleDateFormat().getCalendar();
			System.out.println(y+"/"+m+"/"+d+" "+h+":"+min+":"+s);
			calendar.set(y, (m-1), d, h, min, s);
			
			times = calendar.getTimeInMillis();
			System.out.println("times:::"+times);
			
		} catch (Exception e) {
			return 0;
		}
		
		return times;
	}
	
//	/**
//	 * 获取网络时间
//	 * @return
//	 */
//	public static void NetTime(){
//		
//		URL url;
//		long ld;
//		try {
//			url = new URL("http://www.bjtime.cn");//取得资源对象
//			URLConnection uc=url.openConnection();//生成连接对象
//			uc.connect(); //发出连接
//			uc.setConnectTimeout(1*10000);
//			uc.setReadTimeout(10000);
//			ld=uc.getDate(); //取得网站日期时间
//			
//			netTime = ld;
//		} catch (MalformedURLException e) {
//			netTime = 0;
//		}catch (IOException e) {
//			netTime = 0;
//		}
//	}
	
//	/**
//	 * 获取系统时间
//	 */
//	public static void NetTime(){
//		JsonObjectServices jos = new JsonObjectServices();
//		String resultCode = "";
//		
//		jos.getSysTimeSign();
//		jos.sendPost();
//		resultCode = jos.getResultCode();
//		
//		if (resultCode != null && resultCode.equals("0000")) {
////			Log.e("time", "ok....."+jos.getRes());
//			netTime = JsonToString.getSysTemTime(jos.getRes());
////			System.out.println(netTime);
//		}else{
////			Log.e("time", "error....."+resultCode);
//			netTime = 0;
//		}
//			
//		
//	}
}
